function [finalC, finalPayoff, finalCov] = calcSGWithAllSolutions(gameModel, resourceFunction)
		
		if nargin==1 
              resourceFunction=@resFunct;
			  function res=resFunct(m)
				res=8*m+5;
			  end
        end 
		
	    targets=gameModel.targets;
        Uud    =gameModel.Uud;
        Ucd    =gameModel.Ucd;
        Uua    =gameModel.Uua;
        Uca    =gameModel.Uca;
		C      =gameModel.coverageVector;
	   
       finalPayoff=0;
       finalC=[];
       e=0.05;
       Tsize=length(targets);
       maxPayoff=0;
       minPayoff=Utils.minValue(Uud);
	   
	   
	   Dvalues=minPayoff:e:maxPayoff;
	   
	   
	   feasebleDvalues=[];
	   minCovByD=[];
	   coverageByD=[];
	   resourcePrice=[];
	   for i=1:length(Dvalues)
			[ret,C, minCov]=feasibilityCheck(midPoint,m,C);
		    if strcmp(ret,'true')
               feasebleDvalues=[feasebleDvalues,D];
			   minCovByD=[minCovByD,minCov];
			   coverageByD=[coverageByD,C];
			   resourcePrice=[resourcePrice,resourceFunction(minCov)]
           end
	   end
	   
	   plot(1:length(feasebleDvalues),feasebleDvalues,1:length(minCovByD),minCovByD,1:length(resourcePrice),resourcePrice )
	   
	   totalProfit=feasebleDvalues-resourcePrice;
	   [D,I]=min(totalProfit);
	   finalC=coverageByD(I);
	   
	   
       
       
       
       function [ret,C, minCov]=feasibilityCheck(midPoint,m,C)
        Tsize=length(C);
        e=0.05;
		totalCovs=[];
        for t=1:Tsize
          c1(t)= get_c1(t);
        end
        for t=1:Tsize
            totalCov=c1(t);
            C(t)=c1(t);
            if C(t)>1
              continue  
            end
            R=get_R(c1(t),t);
            for tj=1:Tsize
                if(t==tj)
                    continue
                end
                c2=get_c2(R,tj);
                minCov=min(c1(tj),c2);
                if Utils.ine(minCov,Interval(0,1))==0;
                    break
                end
                totalCov=totalCov+minCov;
                C(tj)=minCov;
            end
            if (Utils.ine(minCov,Interval(0,1))) && totalCov<=m
			    totalCovs(i)=totalCov;
                ret='true';
             end
        end
		minCov=Utils.reduce(@min, totalCov);
        ret='false';
        return 
        
        function c1=get_c1(t)
                %cash=1-(midPoint-Uud(t))/(Ucd(t)-Uud(t));
                cash=(midPoint-Uud(t))/(Ucd(t)-Uud(t));
                c1=max(cash,0);        
            end
            function c2=get_c2(R,t)
                upBound=max(Uua(t),Uca(t));
                lowBound=min(Uua(t),Uca(t));
                if R<lowBound 
                    c2=2;
                    return;
                end

                if R>upBound 
                    c2=0;
                    return;
                end
                cash=(R-Uua(t))/(Uca(t)-Uua(t));
                c2=max(cash,0); 
            end
            function R=get_R(c1,t)
                R=(c1*Uca(t))+((1-c1)*Uua(t)-e);
            end
        end
    end
